$(function(){
	layui.use('form', function () {
		var form = layui.form;
		$("#addSociety").click(function(){
			$.ajax({
				url:"http://localhost:8081/society/addSociety",
				type:"POST",
				dataType:"json",
				accept:"application/json",
				contentType:"application/json",
				data:JSON.stringify($("#addfrom").serializeObject()),
				success: function (data) {
					if(data.code==200){
						 layer.msg("添加成功", {icon: 6, time: 1000});
					}else{
						 layer.msg("添加失败", {icon: 5, time: 1000});
					}
			    },
			    error: function(data){
				    layer.msg(""+data.message+"", {icon: 5, time: 1000});
			   }
			})
			setTimeout('parent.location.reload();',1000);
		})
	});
})
$.fn.serializeObject = function() {
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name]) {
			if (!o[this.name].push) {
				o[this.name] = [ o[this.name] ];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};